package com.wyy;

import com.wyy.mapper.CyUserMapper;
import com.wyy.model.CyUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class MapperApplication {

	public static void main(String[] args){
		String resourcePath = "mybatis-config.xml";
		InputStream inputStream ;
		try {
			inputStream = Resources.getResourceAsStream(resourcePath);
			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream, "online");

			SqlSession sqlSession = sqlSessionFactory.openSession();

			CyUserMapper cyUserMapper = sqlSession.getMapper(CyUserMapper.class);
			CyUser cyUser = cyUserMapper.selectOneById(1L);

			System.out.println(cyUser);


		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
